Image processing device, image processing method, storage medium, and program

ABSTRACT

An image processing device for performing image correction of a scene by detecting whether a specific object is included in an input image of the scene, and that sets a correction parameter based on the detection result to correct the input image.

BACKGROUND OF THE INVENTION

[0001] 1. Field of the Invention

[0002] The present invention relates to an image processing device, image processing method, storage medium, and program for correcting images.

[0003] 2. Description of the Related Art

[0004] Various methods have been disclosed, which relate to an algorithm for correcting contrast, highlight, shadow, or white balance of a digital camera image.

[0005] Japanese Patent Laid-Open No. 11-317959 (U.S. Pat. No. 6,493,468) by the same inventor as this application discloses a method in which image features are determined by the ratio of uneven distribution of color components in a highlight portion of the image, and in which, based on the determination result, the degree of white balance correction, contrast, highlight, and shadow are optimally corrected to reproduce the color of an object.

[0006] In the above-described conventional example, however, the image features are determined from histograms of an overall image, and a correction is performed by using one and the same correction method irrespective of whether the scene is of a person's image or a landscape image. In general, the desired degree of contrast enhancement is different between personal images and landscape images.

SUMMARY OF THE INVENTION

[0007] Accordingly, it is an object of the present invention to solve the above-described problem, and to provide an image processing device capable of changing a correction method in response to whether a specific object is included in an input image.

[0008] It is another object of the present invention to provide an image correcting unit that, when the specific object is a person, performs a corresponding image correction.

[0009] In order to achieve these objects, the present invention provides an image processing device that includes a detector for detecting whether an input image includes a specific object; a setting unit for setting a correction parameter based on the above-described detection result; and a correcting unit for correcting the input image by using the set correction parameter.

[0010] In a further aspect, an image processing method is disclosed, which comprises the steps of creating a histogram of an input image, and then using the histogram to set a first gradation correcting condition. The first gradation correcting condition is then used to correct the input image, after which, a specific object region is extracted from the corrected input image.

[0011] The image processing method further includes the steps of creating a histogram of the extracted specific object region, and then using this histogram to set a second gradation correcting condition. Thereafter, the image in the specific object region is corrected by using the set second gradation correcting condition.

[0012] Other features and advantages of the present invention will be apparent from the following description taken in conjunction with the accompanying drawings, in which like reference characters designate the same or similar parts throughout the figures thereof.

BRIEF DESCRIPTION OF THE DRAWINGS

[0013]FIG. 1 is a block diagram showing the construction of an image processing device according to a first embodiment of the present invention.

[0014]FIG. 2 is a flowchart showing image processing in the first embodiment.

[0015]FIG. 3 is a flowchart showing operational process steps associated with an image input section 2 in the first embodiment.

[0016]FIG. 4 is a flowchart showing a processing flow of image correction in the first embodiment.

[0017]FIG. 5 is a flowchart showing operational process steps associated with a histogram creating section 4 in the first embodiment.

[0018]FIG. 6 is a representation of an example of a histogram in the first embodiment.

[0019]FIG. 7 is a flowchart showing operational process steps associated with a lookup table creating section 6 in the first embodiment.

[0020]FIGS. 8A and 8B are diagrams showing examples of lookup tables held in a lookup table holding section 7 in the first embodiment.

[0021]FIG. 9 is a diagram showing an example of an output object profile in the first embodiment.

[0022]FIG. 10 is a diagram showing an example of an input device profile in the first embodiment.

[0023]FIG. 11 is a diagram showing an example of an output device profile in the first embodiment.

[0024]FIG. 12 is a flowchart showing operational process steps in an image correcting section 8 in the first embodiment.

[0025]FIG. 13 is a flowchart showing operational process steps in a face detection processing section 12 in the first embodiment.

[0026]FIG. 14 is a flowchart showing a flow of image correction processing when using mask data in the first embodiment.

[0027]FIG. 15 is a flowchart showing operational process steps associated with the histogram creating section 4 when using mask data in the first embodiment.

[0028]FIG. 16 is a flowchart showing operational process steps in the lookup table creating section 6 when using mask data in the first embodiment.

[0029]FIGS. 17A and 17B are diagrams showing examples of lookup tables held in the lookup table holding section 7 when using mask data in the first embodiment.

[0030]FIG. 18 is a flowchart showing operational process steps in a file processing section 11 in the first embodiment.

[0031]FIG. 19 is a flowchart showing a processing flow of edge enhancement in the first embodiment.

[0032]FIG. 20 is a table showing examples of photographic information and image data stored in an image buffer 9 in the first embodiment.

[0033]FIG. 21 is a flowchart showing a method for synthesizing a lookup table for correcting gradation reproducibility and color reproducibility in the first embodiment.

[0034]FIG. 22 is a diagram showing examples of the synthesized lookup tables for correcting gradation reproducibility and color reproducibility in the first embodiment.

[0035]FIGS. 23A to 23D are representations of relationship between the posture of a digital camera during photographing and the data developing method in the image buffer 9.

[0036]FIGS. 24A to 24C are representations of a processing flow of face detection.

[0037]FIG. 25 is a block diagram showing the construction of an image processing device according to a second embodiment of the present invention.

[0038]FIG. 26 is a table showing information held in a corrected information holding section 15 in the second embodiment.

[0039]FIG. 27 is a flowchart showing a processing flow of creation of lookup table for exposure correction in a third embodiment of the present invention.

[0040]FIG. 28 is a diagram showing the relationship among the representative luminance, the target luminance, and the desirable luminance range of a face in the third embodiment.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0041] First Embodiment

[0042]FIG. 1 shows a block diagram of the main section of an image processing device according to a first embodiment of the present invention.

[0043] Referring to FIG. 1, this image processing device comprises an image input section 2, image output section 3, histogram creating section 4, histogram holding section 5, lookup table creating section 6, lookup table holding section 7, image correcting section 8, imager buffer 9, image buffer 10 for use in copying, filter processing section 11, face detection processing section 12, and photographic information holding section 13. Here, the image input section 2 reads data from an input image 1, and writes it into the image buffer 9.

[0044] The image output section 3 writes data stored in the image buffer 9 into an output image 14. The histogram creating section 4 creates a histogram based on image data stored in the image buffer 9, and stores the created result in the histogram holding section 5.

[0045] The histogram holding section 5 holds a histogram of the overall image data and a histogram of a mask region.

[0046] The lookup table creating section 6 calculates parameters necessary for correction, based on the histogram stored in histogram holding section 5, and creates a lookup table. In addition, the lookup table creating section 6 synthesizes the aforementioned lookup table and a lookup table for correcting gradation characteristic and color reproducibility, which is held in advance in the lookup table holding section 7. Then, the lookup table creating section 6 stores the synthesized lookup table in the lookup table holding section 7.

[0047] Thus, the lookup table holding section 7 holds the lookup tables created in the lookup table creating section 6 and the lookup table for correcting gradation characteristic and color reproducibility.

[0048] The image correcting section 8 corrects the image stored in the image buffer 9, based on the lookup table stored in the lookup table holding section 7, and then stores the corrected result in the image buffer 10 for use in copying.

[0049] The image buffer 9 and the image buffer 10 are used for copying and holding image data.

[0050] The filter processing section 11 performs enlargement/reduction processing, and edge enhancement in a highlight portion.

[0051] The face detection processing section 12 detects whether specific objects, such as a human face is present. This detection may be based on the image data stored in the image buffer 9. If a human face is detected, the face detection processing section 12 then creates mask data.

[0052] The photographic information holding section 13 holds various types of information such as the camera posture during photography. Other information includes the usage or non-usage of a flash, focal length, and in-focus position (two dimensional), and the like.

[0053] The image processing device can be implemented by, for example, supplying a personal computer with a program for achieving processing or control with respect to each of the sections shown in FIG. 1. Then, CPU of the personal computer executes each processing or control, based on contents of the program.

[0054] Hereinafter, more detailed descriptions of this embodiment will be made using a concrete example.

[0055] Processing Flow in This Embodiment

[0056]FIG. 2 shows processing flow in this embodiment.

[0057] At step S1, in the image input section 2, photographic information and image data of the input image 1 are read, and are developed in the image buffer 9. Operational process steps in the image input section 2 are shown in FIG. 3, and are discussed later.

[0058] At step S2, in the histogram creating section 4, lookup table creating section 6, and image correcting section 8, an image is corrected. Operational steps in these sections are shown in FIG. 4, and are discussed later.

[0059] At step S3, in the face detection processing section 12, face detection processing is performed with respect to the face as the specific object to be detected. Operational process steps in the face detection processing section 12 are shown in FIG. 13, and are discussed later.

[0060] At step S4, it is determined whether any faces are presented, based on the result of the face detection processing. If at least one face is present, the processing advances to step S5. If no face is present, the processing advances to step S6.

[0061] At step S5, in the histogram creating section 4, lookup table creating section 6, and image correcting section 8, the image is corrected by using mask data. Operational process steps in these sections are shown in FIG. 14, and are discussed later.

[0062] At step S6, in the filter processing section 11, filter processing is performed. Operational process steps in the filter processing section 11 are shown in FIG. 18, and are discussed later.

[0063] At step S7, in the image output section 3, the image data and photographic information stored in the image buffer 9 are outputted to the output image 14.

[0064] Photographic Information and Image Data Stored in Input Image 1

[0065]FIG. 20 shows photographic information and image data stored in the input image 1. The photographic information is stored in the photographic information holding section 13, and the image data is stored in the image buffer 9. The image buffer 9 stores mask data in addition to the image data. The photographic information includes information about the posture of a camera (FIG. 23A shows its normal position; four different postures are shown in FIGS. 23A to 23D), the usage or non-usage of a flash, focal lengths, and in-focus positions, an input device (camera) ID and the like.

[0066] Method for Developing Image

[0067]FIG. 3 shows operational process steps associated with the image input section 2. These are more specific descriptions of step S1 shown in FIG. 2.

[0068] At step S11, photographic information is inputted from the input image 1, and is stored in the photographic information holding section 13. An example of photographic information is information specified by the known Exif standard. However, any other information that constitutes information about photographing by a camera or information about image inputting by a scanner, may be used.

[0069] At step S12, the posture of a camera during photographing that is stored in the photographic information holding section 13 is determined, and in accordance with the determination result, the image data obtained from the input image 1 is developed in the image buffer 9.

[0070] When the posture of the camera is as shown in FIG. 23A, the image data is developed in the image buffer as it is. When its posture is as FIG. 23B, the image data is developed after it is rotated 90° to the left; when its posture is as shown in FIG. 23C, the image data is developed after a 90° rotation to the right; and when its posture is as FIG. 23D, the image data is developed after a 180° rotation, whereby the image data is developed in the image buffer so that an up-and-down direction conforms to that in the case shown in FIG. 23A. Thereby, when performing later face detection processing, it is possible to treat a person as being always at a normal position irrespective of the posture of the camera during photography.

[0071] During development, processing for reducing dark noise peculiar to a digital camera is also performed. This processing may include a treatment such as smoothing an image in, for example, portions where the luminance thereof is low and delicately fluctuates.

[0072] Image Correction Processing

[0073]FIG. 4 shows a flow of image correction processing.

[0074] At step 21, in the histogram creating section 4, a histogram is created based on the image data stored in the image buffer 9, and the obtained result is stored in the histogram holding section 5. Operational process steps in the histogram creating section 4 are shown in FIG. 5, and are discussed later.

[0075] At step 22, in the lookup table creating section 6, a lookup table is created. Operational process steps in the lookup table creating section 6 are shown in FIG. 7, and are discussed later.

[0076] At step 23, in the image correcting section 8, the image is corrected. Operational process steps in the image correcting section 8 are shown in FIG. 12, and are discussed later.

[0077] Operations in Histogram Creating Section 4

[0078]FIG. 5 shows operational process steps in the histogram creating section 4. These are more specific descriptions of step S21 shown in FIG. 4.

[0079] At step 31, one pixel of image data is fetched one after another from the image buffer 9. The luminance (R, G, and B values) of respective R(red), G(green), and B(blue) colors are then stored as image data. At step S32, from R, G, and B luminance values of the image data, the luminance L of the pertinent pixel is determined by the following expression.

L=(3*R+6*G+1*B)/10

[0080] At step S33, the histogram stored in the histogram holding section 5 is updated. The histogram holding section 5 holds a histogram HistL having the luminance L, calculated above, and HistR, HistG, and HistB that store the cumulative luminance values of respective R, G, and B colors by luminance L of the pertinent pixel. Any initial state is 0. The following expressions are used to perform histogram updates.

HistR[L]=HistR[L]+R

HistG[L]=HistG[L]+G

HistB[L]=HistB[L]+B

HistL[L]=HistL[L]+1

[0081] At step S34, it is checked whether all pixels have been completed. Otherwise, the processing advances to step S31. Here, a histogram may be created by using color information about some pixels sampled at an appropriate pitch from all pixels, instead of using color information about all pixels.

[0082]FIG. 6 shows an example of a histogram HistL.

[0083] Method for Creating Lookup Table for Correcting Gradation Reproducibility and Color Reproducibility

[0084] The lookup table for correcting gradation reproducibility and color reproducibility refers to a lookup table that, with a view toward achieving a desirable color reproduction, performs an image correction such that the gradation reproduction and color reproduction on printed matter when an image inputted from an input device such as a digital camera is outputted by an output device such as a printer, is brought near to the gradation reproduction and color reproduction implemented by an output object such as a silver salt positive film. A method for creating a lookup table for correcting gradation reproducibility and color reproducibility is explained with reference to FIG. 21.

[0085] At step S121, an output object profile (the relationship between the patch number and the XYZ calorimetric value) shown in FIG. 9, and an output device profile (the relationship between the XYZ colorimetric values and the R, G, and B luminances) shown in FIG. 11 are synthesized. The synthesis method is firstly to search for the patch having the same Y value as the Y value of the XYZ values (a value is provided every patch) of the output object profile out of the output device profile. Then, the R, G, and B values corresponding to the XYZ values of the patch searched from the output device profile, and the patch number of the original output object profile are brought into correspondence with each other, and they are synthesized. The synthesized table represents the relationship between the patch number and the luminances (R, G, and B values) of the output device.

[0086] At step S122, the synthesized table in step S121 and an input device profile shown in FIG. 10 are synthesized. Because the input device profile represents the relationship between the patch number and the luminances (R, G, and B values) of the input device, the synthesis method is to acquire the relationship between the luminances (R, G and B values) of the input device and those of the output device corresponding to the identical patch number. The created table is stored in the lookup table holding section 7, and is used when correcting the image. An example of how it is actually used is described later.

[0087] Examples of Lookup Tables for Correcting Gradation Characteristic and Color Reproducibility

[0088] Lookup tables shown in FIG. 22 are lookup tables LUTRDD, LUTGDD, and LUTBDD for correcting gradation characteristic and color reproducibility that have been created by the above-described method. Intermediate points that are not stored in the table are interpolated by a straight line, and thereby conversion data is created. Points in the vicinity of the opposite ends are interpolated using straight lines between respective points (255, 255) and (0, 0). In this embodiment, linear interpolation is used as interpolation processing. Alternatively, for example, nonlinear interpolation processing employing, for example, a spline curve or a Bezier curve may be used.

[0089] Operations in Lookup Table Creating Section 6

[0090] Operational process steps in the lookup table creating section 6 are shown in FIG. 7. These are more specific descriptions about step S22 shown in FIG. 4.

[0091] At step S41, the maximum luminance of the image is determined from the histogram HistL stored in the histogram holding section 5. In the histogram shown in FIG. 6, the maximum luminance is 252.

[0092] At step S42, the maximum luminance determined at step S41, and a numeral value 255 are each decremented by a predetermined amount (in FIG. 6, the predetermined amount=10), and the luminance LH′ when the maximum luminance becomes larger than the numeral value is determined. More specifically, in this instance, the numerical value starts at 255 and decrements in the manner 245, 235, 225, . . . , and the numerical value is compared with the maximum luminance every time the numerical value is decremented (in FIG. 6, LH′ ultimately becomes 245). Then, a region including pixels of a predetermined percentage (in FIG. 6, 1% of the number of all pixels) is determined. The minimum luminance of this region is assumed as a highlight point LH (in FIG. 6, LH=234). Then, average luminances (RH, GH, and BH) of R, G, and B colors within this region (the region where the luminance thereof is in a range of LH to LH′, both inclusive, is calculated by the following expressions. ${RH} = {\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{{HistR}\lbrack m\rbrack}/{\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{HistL}\lbrack m\rbrack}}}}$ ${GH} = {\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{{HistG}\lbrack m\rbrack}/{\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{HistL}\lbrack m\rbrack}}}}$ ${BH} = {\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{{HistB}\lbrack m\rbrack}/{\sum\limits_{m = {LH}}^{{LH}^{\prime}}{{HistL}\lbrack m\rbrack}}}}$

[0093] At step S43, the minimum luminance of the image is determined from the histogram HistL stored in the histogram holding section 5. In the histogram shown in FIG. 6, the minimum luminance is 6.

[0094] At step S44, the minimum luminance determined at step S43, and a numeral value 0 are each incremented by a predetermined amount (in FIG. 6, the predetermined amount=10), and the luminance LS′ when the minimum luminance becomes smaller than the numeral value is determined (in FIG. 6, LS′ ultimately becomes 10). Then, a region including pixels of a predetermined percentage (in FIG. 6, 1% of the number of all pixels) is determined. The maximum luminance of this region is assumed as a shadow point LS (in FIG. 6, LS=22). Then, the average luminances (RS, GS, and BS) of R, G, and B colors within this region (the region where the luminance is in a range of LS′ to LS, both inclusive, is calculated by the following expressions. ${RS} = {\sum\limits_{m = {LS}^{\prime}}^{LS}{{{HistR}\lbrack m\rbrack}/{\sum\limits_{m = {LS}^{\prime}}^{LS}{{HistL}\lbrack m\rbrack}}}}$ ${GS} = {\sum\limits_{m = {LS}^{\prime}}^{LS}{{{HistG}\lbrack m\rbrack}/{\sum\limits_{m = {LS}^{\prime}}^{LS}{{HistL}\lbrack m\rbrack}}}}$ ${BS} = {\sum\limits_{m = {LS}^{\prime}}^{LS}{{{HistB}\lbrack m\rbrack}/{\sum\limits_{m = {LS}^{\prime}}^{LS}{{HistL}\lbrack m\rbrack}}}}$

[0095] At step S45, lookup tables LUTR, LUTG, and LUTB corresponding to R, G, and B colors, respectively, are created from the determined RH, GH, BH, RS, GS, and BS. FIG. 8A shows examples of the created lookup tables. A more detailed description thereof is given later. Then, at step S46, the average luminance of the image is determined from the Histogram HistL stored in the histogram holding section 5. A lookup table LUTL for exposure correction is created based on the determined average luminance value. FIG. 8B shows an example of a created lookup table. A more detailed description thereof is made later.

[0096] At step S47, the lookup tables LUTR, LUTG, and LUTB; LUTL created in step S46; and the lookup tables LUTRDD, LUTGDD, and LUTBDD stored in advance in the lookup table holding section 7 for correcting gradation characteristic and color reproducibility, are synthesized according to the following expressions. The synthesized lookup tables LUTR2, LUTG2, and LUTB2 are stored in the lookup table holding section 7.

LUTR 2 [i]=LUTRDD[LUTL[LUTR[i]]]

LUTG 2 [i]=LUTGDD[LUTL[LUTG[i]]]

LUTB 2 [i]=LUTBDD[LUTL[LUTB[i]]]

[0097] Here, “i” is a value in a range of 0 to the maximum luminance, both inclusive.

[0098] Examples of Created Lookup Tables

[0099]FIGS. 8A and 8B show examples of the created LUTR, LUTG, LUTB, and LUTL. The lookup tables LUTR, LUTG, and LUTB shown in FIG. 8A are used for correcting contrast and color fogging. Here, gamma (γ) values (described later) of G, B, and R highlights are increased in this order. By enhancing G and B relative to R in this manner, for example, red fog on an image can be corrected. Concurrently, the correction of contrast is also achievable.

[0100] On the other hand, the lookup table LUTL shown in FIG. 8B is one for exposure correction, and is created in accordance with the average luminance of an image. Specifically, when the average luminance is low, there is a high probability of the image being underexposed, and therefore, a table such as to make an overall image brighter is created. Conversely, when the average luminance is high, there is a high probability of the image being overexposed, and therefore, a table such as to make an overall image darker is created.

[0101] Operations in Image Correcting Section 8

[0102]FIG. 12 shows operational process steps in the image correcting section 8. These are more specific descriptions of step S23 shown in FIG. 4 and step S73 shown in FIG. 14. At step S51, one pixel of image data stored in the image buffer 9 is fetched. As image data, luminances (R, G, and B) of RGB colors are stored.

[0103] At step S52, based on the lookup tables LUTR2, LUTG2, and LUTB2 that have been synthesized at step S47 or step S99, the image data fetched from the image buffer 9 is corrected. The corrected result is stored in the image buffer 10 for use in copying.

R=LUTR 2 [R], G=LUTG 2 [G], B=LUTB[B]

[0104] At step S53, it is checked whether all pixels have been completed. If so, the proceeding is finished. Otherwise, the processing advances to step S51.

[0105] In this embodiment, in order to speed up creation processing of lookup tables and image correction processing, lookup tables are prepared for each color component.

[0106] Operations in Face Detection Processing Section 12

[0107]FIGS. 13 and 24 show operational process steps in the face detection processing section 12. These are more specific descriptions of step S3 shown in FIG. 2.

[0108] At step S61, based on the image data stored in the image buffer 9 or image buffer 10 for use in copying (for the latter, the image data is corrected in step S2), regions where the luminance is locally low are marked one after another.

[0109] At step S62, the regions marked in step 61 are paired, and it is determined whether the marked pair are eyes, based on the equality of the sizes of the paired regions, difference in luminance therebetween, angle that they form with respect to the horizon (see FIG. 24A).

[0110] At step S63, with respect to the paired regions determined to be eyes, a rectangular region around the pair regions is set. Then, an edge in the vicinity of the boundary of the rectangular region and color information about the inside of the rectangular region are determined. The edge is used for determining the profile of a face. The color information is used for determining whether the average values of the R, G, and B values of the rectangular region is within a preset skin color region. In this manner, the face region is determined by detecting the position and size of a face. The face region is given by the above-described rectangular region, which is an oblong region of which the opposite horizontal and vertical sides are each parallel to each other (see FIG. 24B (C)).

[0111] At step S64, a mask data such as to mask the determined face region is created, and the created mask data is stored in the image buffer 9. This mask data is information for allowing the face region to be identified.

[0112] Image Correction Processing When Using Mask Data

[0113]FIG. 14 shows a flow of image correction processing when using mask data in this embodiment.

[0114] At step S71, in the histogram creating section 4, a histogram is created based on the image data (the image data before being subjected to the correction in step S2) that has been stored in the image buffer 9, and the created result is stored in the histogram holding section 5. Operational process steps in the histogram creating section 4 are shown in FIG. 15 and are discussed later.

[0115] At step S72, in the lookup table creating section 6, a lookup table is created. Operational process steps in the lookup table creating section 6 are shown in FIG. 16, and are discussed later.

[0116] At step S73, in the image correcting section 8, the image is corrected. Operational process steps in the image correcting section 8 are shown in FIG. 12 in a more detail.

[0117] Histogram Creation Processing When Using Mask Data

[0118]FIG. 15 shows operational process steps in the histogram creating section 4. These are more specific descriptions of step S71 shown in FIG. 14.

[0119] At step 81, one pixel of image data and mask data are each fetched one after another from the image buffer 9.

[0120] At step S82, from the R, G, and B values of the image data, the luminance L of a pertinent pixel is determined by the following expression.

L=(3*R+6*G+1*B)/10

[0121] At step S33, the histogram stored in the histogram holding section 5 is updated. The histogram holding section 5 holds a histogram HistL having the luminance L above calculated; HistR, HistG, and HistB that store the cumulative luminance values of respective R, G, and B colors by luminance L of the pertinent pixel; and a histogram HistLMsk having a luminance L, for a region masked by mask data. Any initial state is 0. The updating of histograms is performed by the following expressions.

HistR[L]=HistR[L]+R

HistG[L]=HistG[L]+G

HistB[L]=HistB[L]+B

HistL[L]=HistL[L]+1

[0122] At step S84, it is checked, based on the mask data, whether the pertinent pixel is masked. If so, the processing advances to step S85. Otherwise, the processing advances to step S86.

[0123] At step S85, a mask region histogram stored in the histogram holding section 5 for calculating the exposure state of the mask region, is updated.

HistLMsk[L]=HistLMsk[L]+1

[0124] At step S86, it is checked whether all pixels have been completed. If so, the processing is finished. Otherwise, the processing advances to step S81.

[0125] Operations in Lookup Table Creating Section 6 When Using Mask Data

[0126]FIG. 16 shows operations in lookup table creating section 6 when using mask data. These are more specific descriptions of step S72 shown in FIG. 14.

[0127] At step S91, the maximum luminance of the image is determined from the histogram HistL stored in the histogram holding section 5.

[0128] At step S92, the maximum luminance determined at step S91, and a numeral value 255 are each decremented by a predetermined amount, and the luminance LH′ when the maximum luminance becomes larger than the numeral value is determined. Then, a region including pixels of a predetermined percentage is determined. The minimum luminance of this region is assumed as a highlight point LH.

[0129] At step S93, the minimum luminance of the image is determined from the histogram HistL stored in the histogram holding section 5.

[0130] The processing steps S91 to 93 are substantially the same as the processing steps S41 to S43 shown in FIG. 7.

[0131] At step S94, the minimum luminance determined at step S93, and a numeral value 0 are each incremented by a predetermined amount (in FIG. 6, the predetermined amount=10), and the luminance LS′ when the minimum luminance becomes smaller than the numeral value is determined (in FIG. 6, LS′ ultimately becomes 10). Then, a region including pixels of a predetermined percentage (in FIG. 6, 1% of the number of all pixels) is determined. The maximum luminance of this-region is assumed as a shadow point LS (in FIG. 6, LS=22). Then, at step S95, the average values (RG, GG, and BG) of respective R, G, and B luminances of pixels that are situated within the region where the luminance thereof is in a range of LS to LH, both inclusive, and that meet the following expressions, are determined.

Max(R, G, B)−Min(R, G, B)≦Thr

[0132] Here, Max (R, G, B) denotes maximum values of the R, G, and B values, and Min (R, G, B) denotes minimum values thereof, and Thr denotes a threshold value.

[0133] At step S96, lookup tables LUTR, LUTG, and LUTB are created from the LS, LH, RG, GG, and BG that have been determined in step 95. FIG. 17A shows examples of the created lookup tables. A more detailed description thereof is given later. The created results are stored in the lookup table holding section 7. Also, a Lookup table LUTTmp for correcting HistL is created based on LH and LS.

[0134] At step S97, HistLMsk is corrected by using the LUTTmp. Thr corrected HistLMsk is used when an exposure correction amount is calculated later.

[0135] At step S98, the average luminance of the mask region is determined from the HistLMsk after subjected to a correction. Then, a lookup table LUTLMsk for exposure correction is created according to a predetermined method. The created result is stored in the lookup table holding section 7. FIG. 17B shows an example of LUTLMsk. A more detailed description thereof is made later.

[0136] At step S99, the lookup tables LUTR, LUTG, LUTB, and LUTLMsk that have been created in step S96 are synthesized by the following expressions. The synthesized lookup tables LUTR2, LUTG2, and LUTB2 are stored in the lookup table holding section 7.

LUTR 2 [i]=LUTLMsk[LUTR[i]]

LUTG 2 [i]=LUTLMsk[LUTG[i]]

LUTB 2 [i]=LUTLMsk[LUTB[i]]

[0137] Here, “i” is a value in the range of 0 to the maximum luminance, both inclusive.

[0138] Examples of Created Lookup Tables

[0139]FIGS. 17A and 17B show examples of the created lookup tables. The lookup tables LUTR, LUTG, and LUTB shown in FIG. 17A are used for correcting color fogging. Here, gamma values of G, B, and R halftones are increased in this order. By enhancing G and B relative to R in this manner, for example, red fog on an image can be corrected. Concurrently, the correction of contrast can also be achieved.

[0140] On the other hand, the lookup table shown in FIG. 17B is a lookup table LUTLMsk for optimally correcting an exposure in the mask region. Here, it is also possible to set the region of a person to a mask region, and to set LUTLMsk so that the exposure of the person can be optimally corrected.

[0141] Operations in Filter Processing Section 11

[0142]FIG. 18 shows operational process steps in the filter processing section 11. These are more specific descriptions of step S6 shown in FIG. 2.

[0143] At step S101, enlargement/reduction processing for the image is performed. A method such as a bicubic method or bilinear method is used for this processing.

[0144] At step S102, edge enhancement processing is performed. Operational process steps of the edge enhancement processing are shown in FIG. 19, and discussed later.

[0145] Edge Enhancement Processing

[0146]FIG. 19 shows a flow of edge enhancement processing. These are more specific descriptions of step S102 shown in FIG. 18.

[0147] First, at step S111, one pixel of R, G, and B luminance data is read from the image buffer 10 for use in copying.

[0148] At step S112, the read RGB luminance data and a threshold value are compared, for each of the R, G, and B colors. If all pieces of R, G, and B luminance data are lower than the threshold value, or the pertinent pixel is one situated at an edge, the processing advances to step S114. Otherwise, the processing advances to step S113.

[0149] At step S113, with respect to color component data having a luminance value of not lower than the threshold value thereof, a filter processing is performed by using an edge enhancement filter of 3×3. No edge filter processing is performed with respect to color component data having a value lower than the threshold value.

[0150] At step S114, the R, G, and B luminance data that has been processed is written into the image buffer 9. When no edge processing is performed, the R, G, and B luminance data that has been read at step S111 is written into the image buffer 9 as it is. At step 115, it is determined whether all pixels have been completed. Otherwise, the processing advances to step S111.

[0151] Meanwhile, as the threshold value used in step S112, one and the same threshold value may be used with respect to all color components. Alternatively, the threshold value may be independently set with respect to each of the color components.

[0152] According to the first embodiment, it is possible to determine whether the face of a person is included in the input image, and to perform a correction in accordance with the determination result. Therefore, if included, the face of the person can be arranged to be appropriately color-reproduced.

[0153] Second Embodiment

[0154] In the first embodiment, when creating a lookup table, as a highlight point and shadow point after correction (i.e., HP and SP shown in FIG. 8A), certain constants are always used. However, the use of the information stored in the photographic information holding section 13 allows highlight points and shadow points after correction to be variable. Hereinafter, a second embodiment of the present invention is described.

[0155]FIG. 25 shows the construction of the main portion of an image processing device according to the second embodiment of the present invention.

[0156] Referring to FIG. 25, this image processing device comprises an image input section 2, image output section 3, histogram creating section 4, histogram holding section 5, lookup table creating section 6, lookup table holding section 7, image correcting section 8, imager buffer 9, image buffer 10 for use in copying, filter processing section 11, face detection processing section 12, photographic information holding section 13, and correction information holding section 15.

[0157] Other than the lookup table creating section 6 and correction information holding section 15, other features of the present embodiment are similar to those of the above-described embodiment, and are therefore omitted.

[0158] Method for Creating Lookup Tables in Second Embodiment

[0159]FIG. 26 shows information stored in the correction information holding section 15.

[0160] As shown in FIG. 26, two conditions: the usage/non-usage of a flash, and the range of an in-focus position, are combined, and in accordance with the combination of these two conditions, highlight points and shadow points after correction are held. As a result, for example, when a flash is used and the focal length is short, that is, when there is a high probability that a highlight disappears, too much enhancement of contrast can be prevented by reducing the value of HP. Conversely, when no flash is used and a focal length is long, that is, when there is a high probability that the photograph is a scenic one, contrast can be enhanced by increasing the value of HP. These HP and SP are put to use by being read from the correction information holding section 15 when creating lookup tables in the lookup table creating section 6 (i.e., at steps S45 and S96).

[0161] Description of Luminance

[0162] In the above-described embodiment, digital values from 0 to 255 are used as luminance data. However, for example, the maximum value of the data is not limited to 255. Furthermore, besides luminance, halftone dot density may also be utilized.

[0163] Method for Calculating Luminance Values

[0164] At steps S32 and S82, the luminance value is determined by weighted average calculation using weights of (R:G:B=3:6:1). However, the calculating method for luminance values is not restricted to this method. For example, weights other than the above-described ones may also be used for weighted average calculation. Furthermore, the luminance may be determined from an average value of the maximum value and minimum value of each of the R, G, and B luminance.

[0165] Method for Representing Face Detection Result

[0166] In the above-described embodiment, the result of face detection, i.e., a mask region, is represented by a rectangle. However, the mask region is not limited to a rectangle. For example, the result of face detection may be a result obtained by extracting a profile portion. The information allowing the mask region to be identified may be information about the width and height based on the coordinate values of the two opposite points of either one of the two diagonal lines of the rectangle (oblong region), or information about the width and height based on the coordinate values of some of the vertexes of the rectangle (oblong region). Moreover, besides rectangle, the information allowing the mask region to be identified may be a circular region (or elliptical region) nearer to a human face. In this case, the information allowing the mask region to be identified is the central coordinate values and the length of the radius of the circular region, or the central coordinate values and the length of the diameter thereof, or four vortexes of a rectangle circumscribing the circular region or the elliptical region. Moreover, the mask region may be a polygonal region representing the shape of a human face. In this case, information allowing the polygonal region to be identified is the coordinates of all vortexes thereof.

[0167] Posture of Camera During Photographing, and Image Data Stored in Image Buffer

[0168] In FIG. 23, the postures of camera during photographing and image data stored in the image buffer are each illustrated for four different cases. However, the postures of camera and image data stored in the image buffer are not restricted to these four kinds. For example, when photographing with a camera inclined by 45°, the image may be stored in the image buffer with the image inclined by 45° in the inverse direction.

[0169] Method for Utilizing Image Information

[0170] In the above-described embodiment, as photographic information, only postures of a camera are used. However, as shown in FIG. 20, the output object profile shown in FIG. 9 may be switched by using an input device ID such as a camera. Also, when attempting to create LUTL for exposure correction, it may be created based on an in-focus position by using an in-focus position.

[0171] Regarding Information Held in Correction Information Holding Section 15

[0172] In the above-described second embodiment, highlight points (HPs) and shadow points (SPs) after correction are held in the correction information holding section 15. However, information to be held in the correction information holding section 15 is not limited to HPs and SPs alone. For example, methods for exposure correction may also be held. As a consequence, when no flash is used and focal length is long, that is, when there is a high probability of an image being underexposed, the exposure correction can be set so as to make the brightness of an image a little higher than in normal cases for optimizing the exposure of the image.

[0173] Third Embodiment

[0174] A third embodiment of the present invention will be now described. The descriptions hereinafter are made of only different parts of the this embodiment from those in the first and second embodiments. In the first and second embodiments, the average luminance of a face region is calculated, and lookup tables are created based on predetermined conversion tables. However, in this embodiment, another system for creating lookup tables for exposure is explained.

[0175] In general, the desirable brightness of a face is regarded as approximately 60 to 80% of the maximum luminance. In the input image, when the average luminance of a detected face region is not within this range (the range of an ideal color), by performing a correction such as to bring the average luminance near to this range, a correction such as to convert the input image into desirable color information (i.e., correction such as to reproduce a desirable human skin color) can be achieved. In the descriptions hereinafter, the desirable brightness of a face is treated as approximately 60 to 80% of the maximum luminance. However, this value is merely an example. Other values may also be adopted.

[0176]FIG. 27 is a flowchart showing a processing flow of the creation of the lookup table for exposure correction. First, at step S2701, a representative luminance (representative color information) of the detected face region is calculated. In this embodiment, as the representative luminance, average pixel value (average luminance) of the luminance values of pixels included in the face region, are used. Therefore, in the same manner as in the first and second embodiments, the average luminance Lface of a mask region corresponding to the face region is determined, and this average luminance Lface is assumed as the representative luminance of the face region.

[0177] A possible modified method for determining the representative luminance is to determine a central value or mode value out of the histogram HistLMsk in a mask region that is the same as the one described in the first embodiment, and to assume this value as the representative luminance Lface. By establishing an arrangement such that, through a user interface of the present device, the user can specify which to select as the representative luminance from among the central value, mode value, and average value, a color correction to suit preference of the user can be implemented.

[0178] At the next step S2702, a target luminance Ltarget is calculated. The target luminance Ltarget is calculated using the following expression (1).

Ltarget=Lface+(LidealMin−Lface)/A (Lface≦LidealMin)

Ltarget=Lface (LidealMin≦Lface≦LidealMax)

Ltarget=Lface−(Lface−LidealMax)/A (LidealMax≦Lface)  Expression (1)

[0179] In the above expressions, LidealMin and LidealMax, respectively, are an upper limit value and lower limit value of the desirable luminance range of a face. In this embodiment, the LidealMin and LidealMax values, respectively, are predetermined to be 60% of the maximum luminance (i.e., 255×0.6=153) and 80% thereof (i.e., 255×0.8=204). “A” is a parameter for controlling a correction amount, and is a number of not less than 1. In the present experiments, satisfactory results were obtained by setting “A” to be on the order of 2 to 4.

[0180] Performing a correction such as to bring the above-described representative luminance (color information) of a mask region near to the ideal color range, comprises the following steps: (1) out of the color information value (defined as C1) of the representative color in the region calculated from all or some of the mask region, and color information values included in the ideal color range, determining a color information value (defined as C2) that is situated at the shortest distance from the color information value C1 of the representative color in a color space defining the above-described color information; (2) determining a color information value (defined as C3) that internally divides the line connecting the color information values C1 and C2; and thereby, (3) correcting the input image so that the color information value C1 becomes the color information value C3. Here, the internal ratio used is a predetermined value.

[0181]FIG. 28 is a diagram showing the relationship among the representative luminance, target luminance, and desirable luminance range of a face. In FIG. 28, the value of “A” is set to 3. Lface 1 and Ltarget 1 are examples in which the respective representative luminances are lower than the lower limit of the desirable luminance range of a face; and Lface 2 and Ltarget 2 are examples in which the respective representative luminances are within the desirable luminance range of a face; and Lface 3 and Ltarget 3 are examples in which the respective representative luminances are higher than the higher limit of the desirable luminance range of a face.

[0182] At step S2703, the gamma (γ) value is calculated from the representative luminance Lface and target luminance Ltarget of the face region. The γ value is calculated by using the following expressions. First, the expression (2) for γ correction is transformed into the expression (3). Then, in the expression (3), Lface is substituted for x, and Ltarget is substituted for y, and thereby a γ value is determined. $\begin{matrix} {Y = {255 \times \left( \frac{x}{255} \right)^{\frac{I}{\gamma}}}} & {{Expression}\quad (2)} \end{matrix}$

[0183] (Here, x is a value before correction; y is a value after correction; and x and y are each values in the range of 0 to the maximum luminance LMAX, both inclusive.) $\begin{matrix} {\gamma = \frac{\log \left( \frac{x}{255} \right)}{\log \left( \frac{y}{255} \right)}} & {{Expression}\quad (3)} \end{matrix}$

[0184] Lastly, at step S2704, the γ value determined in step S2703 is substituted into the expression (2). While varying the value of x from 0 to 255, the value of y corresponding to the value of x is calculated. The calculation results are stored as a lookup table LUTLMsk, in the lookup table holding section 7, as in the case of the first embodiment.

[0185] As described above, a correction such as to bring color information near to the desirable color reproduction range is performed. Specifically, in the γ correction curve: y=LMAX×(x/LMAX)^(1/γ) (where, 0≦x≦LMAX, and 0≦y≦LMAX), the γ value that passes through (x, y)=(C1, C3) is calculated, and the correction of the input image is performed by using the determined curve.

[0186] In the first embodiment, the lookup table for exposure correction, the lookup tables LUTR, LUTG and LUTB for color fogging correction, as well as the calculated lookup tables LUTRDD, LUTGDD, and LUTBDD for color reproducibility correction, are synthesized, and these results are applied to R, G, and B values of pixels of the input image. However, the calculation and synthesis of these lookup tables are not indispensable for the correction system according to this embodiment.

[0187] When the calculation and synthesis of these lookup tables are not performed, LUTR2, LUTG2, and LUTB2 of the first embodiment are equal to LUTLMsk.

[0188] A modified method for color correction can also be utilized in which pixels of the input image are converted from R, G, and B image data into, for example, YCbCr image data, and after its Y has been subjected to a correction by LUTLMsk, the converted data is again returned to R, G, and B image data. Meanwhile, in the above-described embodiments, the γ correction is used as a luminance correction method, but other luminance correction methods may also be employed.

[0189] As described above, according to the correction system of this embodiment, it is possible to perform image correction to match the desirable brightness of a face.

[0190] Other Embodiments

[0191] The present invention may be applied to either a system comprising a plurality of apparatuses (e.g., a host computer, interface unit, reader, printer, etc.), or an apparatus comprising a single device (e.g., a copying machine, facsimile, etc).

[0192] The present invention also incorporates a case where, with a view toward achieving the functions of the above-described embodiments, program codes of software for implementing the functions of the above-described embodiments are supplied to a computer in an apparatus connected to various devices or a system in order to actuate the various devices, and the computer (CPU or MPU) of the system or apparatus is caused to actuate the aforementioned various devices in accordance with the stored program.

[0193] In this case, because the program codes themselves realizes the functions of the above-described embodiments, the program codes themselves, and means for supplying the program codes to the computer, for example, a storage medium storing such program codes, constitute the present invention.

[0194] The storage medium storing such program codes may be, for example, a floppy® disk, hard disk, optical disk, magneto-optical disk, CD-ROM, magnetic tape, nonvolatile memory card, ROM.

[0195] Such program codes are incorporated in the present invention in not only a case where the functions of the above-mentioned embodiment are implemented by the computer executing the supplied program codes, but also in a case where the functions of the above-mentioned embodiment are realized by the program codes cooperating with an operating system (OS) operating on the computer, or other application soft or the like.

[0196] Furthermore, the present invention incorporates a case where the supplied program codes are stored in a memory provided for a function expanding board inserted into the computer or a function expanding unit connected to the computer, and thereafter, based on instructions of the program codes, a CPU or the like provided for the function expanding board or function expanding unit executes some or all of the actual processing operations, thereby implementing the functions of the above-described embodiments through these processing operations.

[0197] As many apparently widely different embodiments of the present invention can be made without departing from the spirit and scope thereof, it is to be understood that the invention is not limited to the specific embodiments thereof except as defined in the appended claims. 

What is claimed is:
 1. An image processing device comprising: detecting means for detecting whether a specific object is included in an input image; setting means for setting a correction parameter based on the detection result; and correcting means for correcting the input image by using the set correction parameter.
 2. The image processing device according to claim 1, wherein the setting means comprises: histogram creating means for creating a histogram of the input image; and table creating means that calculates a highlight, a shadow, and exposure conditions of the image from the histogram, and that creates a lookup table for correction, based on the calculation results.
 3. The image processing device according to claim 1, wherein the specific object is a human face, and wherein the detecting means detects the position and the size of a region of the face to create information allowing the detected region to be identified.
 4. The image processing device according to claim 1, further comprising: histogram creating means for creating a histogram of a brightness component of the input image; calculating means for detecting a highlight and a shadow of the image from the histogram, and calculating a gradation correcting condition; and gradation correcting means for correcting the input image by using the gradation correcting condition, wherein the detecting means detects whether the specific object is included in the input image that has been corrected by the gradation correcting means; and wherein the setting means sets the correction parameter based on the histogram of the region of the detected specific object.
 5. An image processing method comprising the steps of: creating a histogram of an input image; setting a first gradation correcting condition in accordance with the histogram; correcting the input image by using the gradation correcting condition; extracting a specific object region from the corrected input image; creating a histogram of the specific object region that has been extracted; setting a second gradation correcting condition in accordance with the histogram of the specific object region that has been created; and correcting the image in the specific object region by using the set second gradation correcting condition.
 6. The image processing method according to claim 5, wherein the first gradation correcting condition comprises performing a correction in accordance with a highlight and a shadow of the input image.
 7. The image processing method according to claim 6, further comprises a step of performing an exposure correction with respect to the input image.
 8. The image processing method according to claim 7, the exposure correction step comprises determining an exposure correcting condition in response to an in-focus position included in photographic information about the input image.
 9. The image processing method according to claim 6, further comprises a step of rotating the input image in response to a posture during photographing, the posture being included in the photographic information about the input image.
 10. The image processing method according to claim 6, further comprising the steps of: determining a statistical value of the specific object region; determining a target value from the statistical value; and determining the second gradation correcting condition by using the target value.
 11. A recording medium on which a program for implementing the image processing method as recited in claim 6, is recorded.
 12. An image processing method comprising: detecting step for detecting whether a specific object is included in an input image; setting step for setting a correction parameter based on the detection result; and correcting step for correcting the input image by using the set correction parameter.
 13. An image processing system comprising: means for generating a histogram of an input image; means for setting a first gradation correcting condition based on the histogram; means for correcting the input image by using the gradation correcting condition; means for extracting a specific object region from the corrected input image; means for creating a histogram of the specific object region that has been extracted; means for setting a second gradation correcting condition in accordance with the histogram of the specific object region; and means for correcting the image in the specific object region by using the set second gradation correcting condition.
 14. The image processing system according to claim 13, wherein the first gradation correcting condition comprises performing a correction in accordance with a highlight and a shadow of the input image. 